package hmvc.j2me.component;

import hmvc.j2me.ITerminateAble;
import hmvc.j2me.controller.IController;
import hmvc.j2me.events.IEvent;
import hmvc.j2me.events.IEventListener;
import hmvc.j2me.model.IModel;
import hmvc.j2me.view.IView;

/*
 * Copyright 2008 Jens Meiss
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */



/**
 * This Interface defines the Composition of Model-View-Controller and extending it to get an full working HMVC-Component
 *
 * @author   jens.meiss
 */
public interface IComponent extends ITerminateAble {

	/**
	 * adds an Child-Component to the vectorChildComponents
	 * @param component
	 */
	public void addChildComponent(IComponent component);
	
	/**
	 * adds an Controller-Only-Child-Component
	 */
	public IComponent addChildComponent(IController controller);

	/**
	 * adds an Controller-Model-Child-Component
	 * 
	 * @param controller
	 * @param model
	 * @return IComponent
	 */
	public IComponent addChildComponent(IController controller, IModel model);
	
	/**
	 * adds an Controller-Model-View-Child-Component
	 * 
	 * @param controller
	 * @param model
	 * @param view
	 * @return IComponent
	 */
	public IComponent addChildComponent(IController controller,
			IModel model, IView view);

	/**
	 * adds an View-Controller-Child-Component
	 * 
	 * @param controller
	 * @param view
	 * @return IComponent
	 */
	public IComponent addChildComponent(IController controller, IView view);

	/**
	 * adds an Object to the listTerminatedChild
	 * 
	 * @param component
	 */
	public void addTerminatedChildComponent(IComponent component);

	/**
	 * containing the component as an child component?
	 * 
	 * @param the class of the controller-part of the component
	 * @return boolean
	 */
	public boolean containsChildComponent(Class classOfController);
	
	/**
	 * fires the event to the given directon
	 * 
	 * @param event
	 * @param up
	 * @param local
	 * @param down
	 */
	public void fireEvent(IEvent event, boolean up, boolean local, boolean down);
	
	/**
	 * fires the event Down
	 */
	public void fireEventDown(IEvent event);
	
	/**
	 * fires the event to the local listeners
	 */
	public void fireEventLocal(IEvent event);
	
	/**
	 * fires the event Up
	 */
	public void fireEventUp(IEvent event);
	
	/**
	 * getter for the Controller of the Component
	 * 
	 * @return IController
	 */
	public IController getController();

	/**
	 * getter for the Model of the Component
	 * 
	 * @return IModel
	 */
	public IModel getModel();

	/**
	 * getter for the Parent-Component
	 */
	public IComponent getParentComponent();

	/**
	 * getter for the View of the Component
	 */
	public IView getView();

	/**
	 * registers an EventListener for Events with the given Class
	 * 
	 * @param classOfEvent
	 * @param listener
	 */
	public void register(Class classOfEvent, IEventListener listener);

	/**
	 * removes all Terminated Child-Components
	 */
	public void removeTerminatedChildComponents();

	/**
	 * setter for the Controller of the Component
	 */
	public void setController(IController controller);

	/**
	 * setter for the Model of the Component
	 */
	public void setModel(IModel model);

	/**
	 * setter of the parent-Component
	 * @param  controller
	 */
	public void setParentComponent(IComponent parentComponent);
	
	/**
	 * setter for the View of the Component
	 * @param  view
	 */
	public void setView(IView view);
	
	/**
	 * conntects all parts of the Component
	 */
	public void connectComponentParts();
	
	/**
	 * calls init() on all Component-Parts
	 */
	public void initComponentParts();
	
}
